package control

import (
	"github.com/lerryxiao/gin"
)

// SetRouter 注册路由
func SetRouter(engin *gin.Engine) {

	{
		engin.Static("/page/js", "./static/js")
		engin.Static("/page/css", "./static/css")
		engin.LoadHTMLGlob("./static/html/*")

		pageRouter := engin.Group("/page")
		{
			pageRouter.Use(gin.BasicAuth(gin.Accounts{"admin": "admin"}))
			pageRouter.GET("/lampList", pageLampList)
			pageRouter.GET("/lampOnOff", pageLampOnOff)
			pageRouter.GET("/boardList", pageBoardList)
			pageRouter.GET("/index", pageIndex)
			pageRouter.GET("/", pageIndex)
		}
	}

	lamp := engin.Group("lamp") // 灯
	{
		lamp.GET("/list", lampList)
		lamp.POST("/list", lampList)

		lamp.GET("/on", lampOn)
		lamp.POST("/on", lampOn)

		lamp.GET("/off", lampOff)
		lamp.POST("/off", lampOff)

		lamp.POST("/edit", lampEdit)
	}

	board := engin.Group("board") // 开发板
	{
		board.GET("/info", boardInfo)
		board.POST("/info", boardInfo)

		board.POST("/edit", boardEdit)
	}
}
